package com.threeox.commonlibrary.ui.view.impl;

import android.content.Context;
import android.widget.LinearLayout;

import com.alibaba.fastjson.JSONObject;
import com.threeox.commonlibrary.entity.engine.model.layout.CommandMsg;
import com.threeox.commonlibrary.entity.engine.model.layout.ModelMessage;
import com.threeox.commonlibrary.entity.engine.request.RequestMsg;
import com.threeox.commonlibrary.entity.engine.request.base.BaseRequestMsg;
import com.threeox.commonlibrary.ui.view.impl.base.CommonModelExtend;
import com.threeox.commonlibrary.ui.view.inter.engine.model.IModelExtend;
import com.threeox.commonlibrary.ui.view.engineview.model.ModelBaseView;

/**
 *
 * @ClassName: AbstractModelExtend
 *
 * @Description: TODO(抽象的布局扩展类)
 *
 * @author 赵屈犇
 *
 * @date 创建时间: 2017/6/30 16:25
 *
 * @version 1.0
 *
 */
public abstract class AbstractModelExtend<T> extends CommonModelExtend implements IModelExtend<T> {

    protected Context mContext;
    protected LinearLayout mModelLayout;
    protected ModelMessage mModelMessage;
    protected ModelBaseView mModelBaseView;

    @Override
    public void init(Context context, ModelBaseView modelBaseView) {
        this.mContext = context;
        this.mModelBaseView = modelBaseView;
        this.mModelLayout = mModelBaseView.getModelLayout();
        this.mModelMessage = mModelBaseView.getModelMessage();
        initBaseExtend(mModelBaseView);
        initView();
        initData();
        setListener();
    }

    @Override
    public boolean onBeforeExecRequest(RequestMsg requestMsg) {
        return true;
    }

    @Override
    public boolean onBeforeRequestSuccess(BaseRequestMsg requestMsg, String url, int id, String msg, T data) {
        return true;
    }

    @Override
    public void onAfterRequestSuccess(BaseRequestMsg requestMsg, String url, int id, String msg, T data) {

    }

    @Override
    public boolean onBeforeCommand(RequestMsg requestMsg, CommandMsg commandmsg, JSONObject data) throws Exception {
        return true;
    }

    @Override
    public boolean onAfterCommand(RequestMsg commandtype, CommandMsg commandmsg, JSONObject data) {
        return true;
    }

}